package com.aptemo.webetek.client.widgets.betslip;

import com.aptemo.webetek.client.WebetekUserServiceAsync;
import com.aptemo.webetek.client.events.DeleteStakePickEvent;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.HasText;

public class BetSlipRowPresenter
{

	public interface Display
	{
		HasText getBetTitleField();

		HasText getPickTitleField();

		HasText getPickMode();

		HasText getPickWin();

		HasText getStakeOdds();

		HasClickHandlers getRemoveButton();

		HasClickHandlers getAdminRemoveButton();

		void addAdminMenu();

		void addUserMenu();

		String getId();
	}

	private Display			mdisplay;
	private HandlerManager	meventbus;

	public BetSlipRowPresenter(HandlerManager eventbus, Display display, WebetekUserServiceAsync rpc)
	{
		meventbus = eventbus;

		bindDisplay(display);
	}

	private void bindDisplay(Display display)
	{

		mdisplay = display;

		mdisplay.getRemoveButton().addClickHandler(new ClickHandler()
		{

			@Override
			public void onClick(ClickEvent event)
			{
				// remove picked stake
				meventbus.fireEvent(new DeleteStakePickEvent(mdisplay.getId(), false));

			}
		});

		mdisplay.getAdminRemoveButton().addClickHandler(new ClickHandler()
		{

			@Override
			public void onClick(ClickEvent event)
			{
				// remove stake...
				String id = mdisplay.getId();
				meventbus.fireEvent(new DeleteStakePickEvent(mdisplay.getId(), true));
			}
		});

	}
}
